This invention is in the field of passivation techniques for photodetector surfaces. In particular, it is concerned with a new method of passivating mercury cadmium telluride (HgCdTe) surfaces by anodizing. The surfaces are deposited as thin layers of HgCdTe on a CdTe substrate. An old method of anodizing surfaces on solid HgCdTe body is shown in U.S. Pat. No. 3,977,018 of Aug. 24, 1976. This patent teaches a method that uses a constant direct current for anodizing. Unfortuanately, it has been found in practice that the patent method has certain disadvantages. Specifically, the method will not provide a uniform anodic oxide surface if there are nonuniformities (peaks) on the HgCdTe surface. In the case of a thin HgCdTe layer on a CdTe substrate, such nonuniformities as normally occur and which can be smoothed by mechanical or chemical polishing on a solid body of HgCdTe, cannot be so removed because of the danger of damaging the thin layer. Moreover, the oxide surface, notwithstanding the patent teaching of providing a uniform thickness, has thickness variations and pinholes. The instant inventive method overcomes these disadvantages.